#ifndef SDOBJECT_H
#define SDOBJECT_H

#include <vector>
#include <math.h>
#include <iostream>
#include "../src/chipmunk.h"
//#include "sdUniverse.h"

class sdObject {
protected:
    cpBody* body_;
    std::vector<cpShape*> shapeList_;
        
private:
    sdObject();

public:
    inline sdObject(cpBody* body) : body_(body) {}
    inline ~sdObject() {};
    
    inline cpBody& getBody() {return *body_;}
    inline std::vector<cpShape*>& getShapes() {return shapeList_;}
    
    void addCircleShape(cpFloat inner, cpFloat outer, cpVect offset, int ctype);
    void addPolyShape(int numVerts, cpVect* verts, cpVect offset, int ctype);
    
    void setMass(cpFloat mass);
    //cpFloat getMass() {return &getBody();}
    
    inline void setPos(cpVect pos) {body_->p = pos;}
    inline cpVect& getPos() {return body_->p;}
    
    inline void setVel(cpVect vel) {body_->v = vel;}
    inline cpVect& getVel() {return body_->v;}
    
    inline void setAngle(cpFloat pos) {body_->a = pos;}
    inline cpFloat& getAngle() {return body_->a;}
    
    //void insert();
    //virtual void update(cpFloat ticks);
    
    //TODO: MAKE VIRTUAL
    void destroy(cpSpace* space) {
		for(std::vector<cpShape*>::iterator it = shapeList_.begin(); it != shapeList_.end(); ++it) {
            cpSpaceRemoveShape(space, (*it));
        }
        
        cpSpaceRemoveBody(space, body_);
    }
    
    void draw() {}
    virtual void collide(sdObject* rhs) {
        std::cout << "Hi, I collided" << std::endl;// with P[" << &rhs << "] MyBody[" << this->getMass() << "]" << std::endl;
    }
};

#endif
